package com.xjprojectc.uitl;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class GetMacAddress
{
  public static String getOSName()
  {
    return System.getProperty("os.name").toLowerCase();
  }

  public static String getUnixMACAddress()
  {
    String str1 = null;
    BufferedReader localBufferedReader = null;
    Process localProcess = null;
    try
    {
      localProcess = Runtime.getRuntime().exec("ifconfig eth0");
      localBufferedReader = new BufferedReader(new InputStreamReader(localProcess.getInputStream()));

      String str2 = null;
      int i = -1;
      do { if ((str2 = localBufferedReader.readLine()) == null) {
          break;
        }

        i = str2.toLowerCase().indexOf("hwaddr"); }


      while (i == -1);

      label86: str1 = str2.substring(i + "hwaddr".length() + 1).trim();
    }
    catch (IOException localIOException3)
    {
      localIOException3.printStackTrace();
    } finally {
      try {
        if (localBufferedReader != null)
          localBufferedReader.close();
      }
      catch (IOException localIOException4) {
        localIOException4.printStackTrace();
      }
      localBufferedReader = null;
      localProcess = null;
    }

    return str1;
  }

  public static String getLinuxMACAddress()
  {
    String str1 = null;
    BufferedReader localBufferedReader = null;
    Process localProcess = null;
    try
    {
      localProcess = Runtime.getRuntime().exec("ifconfig eth0");
      localBufferedReader = new BufferedReader(new InputStreamReader(localProcess.getInputStream()));

      String str2 = null;
      int i = -1;
      do { if ((str2 = localBufferedReader.readLine()) == null) break;
        i = str2.toLowerCase().indexOf("硬件地址"); }


      while (i == -1);

      label80: str1 = str2.substring(i + 4).trim();
    }
    catch (IOException localIOException3)
    {
      localIOException3.printStackTrace();
    } finally {
      try {
        if (localBufferedReader != null)
          localBufferedReader.close();
      }
      catch (IOException localIOException4) {
        localIOException4.printStackTrace();
      }
      localBufferedReader = null;
      localProcess = null;
    }

    return str1;
  }

  public static String getWindowsMACAddress()
  {
    String str1 = null;
    BufferedReader localBufferedReader = null;
    Process localProcess = null;
    try
    {
      localProcess = Runtime.getRuntime().exec("ipconfig /all");
      localBufferedReader = new BufferedReader(new InputStreamReader(localProcess.getInputStream()));

      String str2 = null;
      int i = -1;
      while ((str2 = localBufferedReader.readLine()) != null)
      {
        i = str2.toLowerCase().indexOf("physical address");
        if (i != -1);
        i = str2.indexOf(":");
        if (i == -1) {
          continue;
        }

        str1 = str2.substring(i + 1).trim();
      }

    }
    catch (IOException localIOException3)
    {
      localIOException3.printStackTrace();
    } finally {
      try {
        if (localBufferedReader != null)
          localBufferedReader.close();
      }
      catch (IOException localIOException4) {
        localIOException4.printStackTrace();
      }
      localBufferedReader = null;
      localProcess = null;
    }

    return str1;
  }

  public static void main(String[] paramArrayOfString)
  {
    String str1 = getOSName();
    System.out.println(str1);
    String str2;
    if (str1.startsWith("windows")) {
      str2 = getWindowsMACAddress();
      System.out.println("本地是windows:" + str2);
    } else if (str1.startsWith("linux")) {
      str2 = getLinuxMACAddress();
      System.out.println("本地是Linux系统,MAC地址是:" + str2);
    } else {
      str2 = getUnixMACAddress();
      System.out.println("本地是Unix系统 MAC地址是:" + str2);
    }
    regString();
  }

  public static String regString() {
    String str1 = getOSName();
    String str2 = "76ybfj";
    String str3 = "DG8SDJHDS9HSDJKHKJSD^%$#$&(*^%$%$%#%^%&&^";
    MD5 localMD5 = new MD5();
    if (str1.startsWith("windows")) {
      str2 = getWindowsMACAddress();
      if (str2 == null) str2 = "76ybfjw";
      return localMD5.getMD5ofStr(str2.toString()).substring(0, 6);
    }if (str1.startsWith("linux")) {
      str2 = getLinuxMACAddress();
      if (str2 == null) str2 = "76ybfjwl";
      return localMD5.getMD5ofStr(str2.toString()).substring(0, 6);
    }
    str2 = getUnixMACAddress();
    if (str2 == null) str2 = "76ybfjwn";
    return localMD5.getMD5ofStr(str2.toString()).substring(0, 6);
  }

  public static String regString1(String paramString)
  {
    String str1 = getOSName();
    String str2 = "76ybfj";
    String str3 = "shuzituteng";
    MD5 localMD5 = new MD5();
    return localMD5.getMD5ofStr(str3 + paramString);
  }
}